<?php
/**
 * Created by PhpStorm.
 * 阿里云日志服务操作
 * User: caicm
 * Date: 2017/3/16
 * Time: 20:23
 */

namespace SDXApi\Service;


class AliyunLogService {

    protected $aliyun_log;

    public function __construct()
    {
        import('Vendor.AliyunLog.LogBehavior');
        $this->aliyun_log = \LogBehavior::boot();
    }

    /*
     * 查询日志列表
     * Created By caicm
     * @param $query 查询条件
     * @param $limit 获取数量
     * @param $topic
     * @param $from 查询开始时间戳
     * @param $to 查询结束时间戳
     * return mixed
     */
    public function get_log_list($query = '', $limit = '', $topic = "sdx", $from = 0, $to = ''){

        return $this->aliyun_log->findLogList($query, $limit, $topic, $from, $to);

    }

    /*
     * 写入日志
     * Created By caicm
     * @param array $contents
     * @param string $topic
     * @param $source
     * return mixed
     */
    public function write_log($contents, $topic='sdx', $source=''){

        return $this->aliyun_log->writeInLog($contents, $topic, $source);

    }

    /*
     * 写入日志(批量)
     * Created By caicm
     * @param array $contents
     * @param string $topic
     * @param $source
     * return mixed
     */
    public function write_log_all($contents, $topic='sdx', $source=''){

        return $this->aliyun_log->writeInLogAll($contents, $topic, $source);

    }

}